﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Shpm.App.Input.Dao;
using Shpm.App.Input.Bean;
using System.Web.UI.HtmlControls;
using Shpm.App.Commons.Utils;

public partial class App_Input_PhysicalPersonSearchForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ViewState["PERSON_ID"] = (string)Context.Items["PERSON_ID"];

            //if (Context.Items["LST_LOAD"] != null) ViewState["LST_LOAD"] = (bool)Context.Items["LST_LOAD"];
            ViewState["TXT_PERSONID"] = (string)Context.Items["TXT_PERSONID"];
            ViewState["TXT_NAME"] = (string)Context.Items["TXT_NAME"];
            ViewState["TXT_DATE"] = (string)Context.Items["TXT_DATE"];
            ViewState["TXT_END_DATE"] = (string)Context.Items["TXT_END_DATE"];
            if (Context.Items.Contains("PersonParamPageIndex"))
            {
                this.ViewState["PersonParamPageIndex"] = Convert.ToString(this.Context.Items["PersonParamPageIndex"]);
                this.GridView1.PageIndex = Convert.ToInt32(this.ViewState["PersonParamPageIndex"]);
            }
       
        }
        if (Context.Items.Contains("ParamPageIndex"))
        {
            this.ViewState["ParamPageIndex"] = (string)Context.Items["ParamPageIndex"];
        }
    }

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        PhyscalDao dao = new PhyscalDao();
        PhyscalBean bean = new PhyscalBean();
        bean.PersonId = Convert.ToInt32(ViewState["PERSON_ID"]);
        IList list = dao.FindByPhyscalInfo(bean);
        GridView1.DataSource = list;
        GridView1.DataBind();
    }

    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        string PhysicalId = null;

        //获取编辑所要的主键
        int index = Convert.ToInt32(e.NewEditIndex);
        DataKey key = GridView1.DataKeys[index];
        PhysicalId = Convert.ToString(key.Value);

        string url = "~/App/Input/PhysicalRegisteForm.aspx";

        //Context.Items["LST_LOAD"] = Convert.ToString(this.ViewState["LST_LOAD"]);
        Context.Items["TXT_PERSONID"] = Convert.ToString(this.ViewState["TXT_PERSONID"]);
        Context.Items["TXT_NAME"] = Convert.ToString(this.ViewState["TXT_NAME"]);
        Context.Items["TXT_DATE"] = Convert.ToString(this.ViewState["TXT_DATE"]);
        Context.Items["TXT_END_DATE"] = Convert.ToString(this.ViewState["TXT_END_DATE"]);
        Context.Items["PERSON_ID"] = Convert.ToString(this.ViewState["PERSON_ID"]);
        Context.Items["ParamPageIndex"] = Convert.ToString(this.ViewState["ParamPageIndex"]);
        Context.Items["PersonParamPageIndex"] = GridView1.PageIndex;
        Context.Items["PHYSICAL_ID"] = PhysicalId;

        //跳转到新页面
        ControllerUtils.Transfer(Context, url, true);
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        //翻页
        GridView1.PageIndex = e.NewPageIndex;
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        //Context.Items["LST_LOAD"] = Convert.ToString(this.ViewState["LST_LOAD"]);
        Context.Items["TXT_PERSONID"] = Convert.ToString(this.ViewState["TXT_PERSONID"]);
        Context.Items["TXT_NAME"] = Convert.ToString(this.ViewState["TXT_NAME"]);
        Context.Items["TXT_DATE"] = Convert.ToString(this.ViewState["TXT_DATE"]);
        Context.Items["TXT_END_DATE"] = Convert.ToString(this.ViewState["TXT_END_DATE"]);
        Context.Items["PERSON_ID"] = Convert.ToString(this.ViewState["PERSON_ID"]);
        Context.Items["ParamPageIndex"] = Convert.ToString(this.ViewState["ParamPageIndex"]);
        string url = "~/App/Input/PhysicalSearchForm.aspx";
        //跳转到新页面
        ControllerUtils.Transfer(Context, url, true);
    }
}
